<template>
	<view class="content">
		<view class="ipts">
			<view class="info-item">
				<view class="info-item-left">
					<image src="../../static/phone.png" mode=""></image>
					<view class="shuxian"></view>
				</view>
				<input type="text" v-model="mobile" placeholder="请输入手机号" placeholder-class="place-class">
			</view>
			<view class="hengxian"></view>
			<view class="info-item">
				<view class="info-item-left">
					<image src="../../static/yzm.png" mode=""></image>
					<view class="shuxian"></view>
				</view>
				<input type="text" v-model="myCode" placeholder="请输入验证码" placeholder-class="place-class">
				<view class="test-code" @click="getCode">获取验证码</view>
			</view>
			<view class="hengxian"></view>
			<view class="info-item">
				<view class="info-item-left">
					<image src="../../static/suo.png" mode=""></image>
					<view class="shuxian"></view>
				</view>
				<input v-model="pswd" type="text" placeholder="请重设密码" placeholder-class="place-class">
			</view>
		</view>
		<view class="butn" @click="subimit">确定</view>
	</view>
</template>

<script>
	import request from '../../common/request.js'
	export default {
		data() {
			return {
				mobile: '',
				myCode: '',
				pswd:''
			};
		},
		onLoad() {
			this.userinfo=this.user
		},
		onShow() {
		
		},
		//下拉刷新
		onPullDownRefresh(){
			this.page=1
			 setTimeout(function() {
			 	uni.stopPullDownRefresh();
			 }, 500);
			this.getInstallDetail()
		},
		onReachBottom() {
			this.page++
			this.getInstallDetail()
		},
		methods: {
			getCode() {
				let that =  this
				if(that.mobile == '') {
					uni.showToast({
						title: '请输入手机号',
						icon: 'none'
					})
					return
				}
				if(!(/^1[3456789]\d{9}$/.test(that.mobile))){
					uni.showToast({
						title: '手机号格式不正确',
						icon: 'none'
					})
					return
				}
				request.request({
					url: '/sms/send',
					method: 'POST',
					data: {
						mobile: that.mobile,
						event: 'resetpwd'
					}
				}).then(res => {
					if(res.data.code == 1) {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},
			subimit() {
				let that = this
				if(that.mobile == '') {
					uni.showToast({
						title: '请输入手机号',
						icon: none
					})
					return
				}
				if(that.myCode == '') {
					uni.showToast({
						title: '请输入验证码',
						icon: none
					})
					return
				}
				if(that.pswd == '') {
					uni.showToast({
						title: '请输入新密码',
						icon: none
					})
					return
				}
				request.request({
					url: '/common/resetpwd',
					method:'POST',
					data: {
						mobile: that.mobile,
						captcha: that.myCode,
						newpassword: that.pswd
					}
				}).then(res => {
					if(res.data.code == 1) {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}else{
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			}
		},
		
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F5F5F5;
		// padding-bottom: 200upx;
		// margin-bottom: 150upx;
	}
	.content{
		padding-bottom: 140upx;
	}
	.ipts{
		background-color: #fff;
		margin-top: 30upx;
	}
	.info-item{
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 100upx;
		width: 100%;
		padding: 0 30upx;
		background-color: #fff;
		font-size: 32upx;
		color: #333;
		input{
			flex: 1;
			text-align: left;
		}
		.info-item-left{
			display: flex;
			width: 10%;
			image{
				width: 32upx;
				height: 32upx;
				margin-right: 8upx;
			}
			.shuxian{
				width: 2upx;
				height: 32upx;
				background: #dddddd;
				border-radius: 2upx;
			}
		}
	}
	.hengxian{
		width: 700upx;
		height: 2upx;
		background-color:  #dddddd;
		margin: 0 auto;
	}
	.place-class{
		font-size: 24upx;
		color: #999;
	}
	.test-code{
		padding: 2upx 10upx;
		font-size: 24upx;
		color: #003690;
		border: 2upx solid #003690;
		border-radius: 8upx;
	}
	.test-code:active{
		background: rgba(69, 82, 202, 0.4);
		color: #fff;
	}
</style>
